package com.matriq.cloudmanager;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import com.matriq.cloudmanager.R;
import com.matriq.cloudmanager.fragment.ConsoleFragment;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.design.widget.TabLayout.OnTabSelectedListener;
import android.support.design.widget.TabLayout.Tab;
import android.support.v4.app.Fragment;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import net.lgpage.activity.BaseFragmentActivity;
import net.lgpage.util.MyFragmentPagerAdapter;

public class ConsoleActivity extends BaseFragmentActivity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ac_console);
		setViews();
		setEvents();
		loadData();
	}

	android.support.design.widget.TabLayout tl;
	LinearLayout viewActionBar;
	TextView tv_title;
	LinearLayout ll_add;
	android.support.v4.view.ViewPager vp;
	ImageButton ll_back;
	LinearLayout ll_search;
	List<Fragment> fmlist;
	MyFragmentPagerAdapter pa;

	private void setViews() {
		ll_search = (LinearLayout) findViewById(R.id.ll_search);
		tl = (android.support.design.widget.TabLayout) this.findViewById(R.id.tl);
		viewActionBar = (LinearLayout) this.findViewById(R.id.viewActionBar);
		tv_title = (TextView) this.findViewById(R.id.tv_title);
		ll_add = (LinearLayout) this.findViewById(R.id.ll_add);
		vp = (android.support.v4.view.ViewPager) this.findViewById(R.id.vp);
		fmlist = new ArrayList<>();
		for(int i = 0;i<3;i++){
			ConsoleFragment fm = new ConsoleFragment();
			Bundle bd = new Bundle();
			bd.putInt("index", i);
			fm.setArguments(bd);
			fmlist.add(fm);
		}
		String titles[] = {"首页","科技","体育"};
		pa = new MyFragmentPagerAdapter(getSupportFragmentManager(), fmlist,Arrays.asList(titles));
		vp.setAdapter(pa);
		ll_back = (ImageButton) this.findViewById(R.id.ll_back);
		tl.setTabMode(TabLayout.MODE_FIXED);  
		tl.addTab(tl.newTab().setText("首页"));
		tl.addTab(tl.newTab().setText("科技"));
		tl.addTab(tl.newTab().setText("体育"));
		tl.setupWithViewPager(vp);
	}

	private void setEvents() {
	}

	class ViewHolder {
		ImageView iv;
	}

	Object obj;

	public void setData(Object obj) {
		this.obj = obj;
		tv_title.setText(null);
	}

	private void loadData() {
		
		
	}

	@Override
	public void onDestroy() {

		super.onDestroy();
	}

}